package com.java.console;

import com.java.Company;
import com.java.thread.Calculate;
import com.java.thread.Print;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author
 * @date 2018/9/13 14:10
 */
public class ExecutorDemo {

    public static void main(String[] args) throws InterruptedException {
        //初始化companyList
        List<Company> companyList = new ArrayList<Company>();
        for (int i = 0; i < 1000; i++) {
            Company company = new Company(i);
            companyList.add(company);
        }
        //多线程修改company信息
        Calculate calculate = new Calculate();
        ExecutorService executor = Executors.newCachedThreadPool();
        for (int i = 0; i < companyList.size(); i++) {
           // executor.execute(new Calculate(companyList.get(i)));
//            calculate.setCompany(companyList.get(i));
//            executor.execute(calculate);
        }
        executor.shutdown();
        while (!executor.isTerminated()) {

        }
        System.out.println(companyList);
    }
}
